package com.google.code.jcooky.chat.client.config;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Configure {
	private static Configure instance = new Configure();
	private Properties props = new Properties();
	
	public Configure() {
		load();
	}
	
	public static Configure getInstance() {
		return instance;
	}
	
	private void load() {
		InputStream is = null;
		try {
			is = getClass().getResourceAsStream("config.xml");
			props.loadFromXML(is);
		} catch(IOException e) {
			throw new RuntimeException(e);
		} finally {
			if(is != null) try { is.close(); } catch(IOException e) {}
		}
	}
	
	public int getInt(String key) {
		return Integer.parseInt(props.getProperty(key));
	}
	
	public String getString(String key) {
		return props.getProperty(key);
	}
}
